<template>
  <div>
    <div class="userinfo" @click="setting">
      <div class="left">
        <div class="avatar">
          <!--<img :src="img_prefix_url + userInfo.imageUrl" alt="">-->
          <van-image
              round
              width="1.2rem"
              height="1.2rem"
              :src="img_prefix_url + userinfo.imageUrl"
          />
        </div>
        <div class="info">
          <h2>{{ userinfo.name }}</h2>
          <p>{{ userinfo.email }}</p>
        </div>
      </div>
      <div class="right">
        <div class="setting">
          <van-icon name="setting-o"/>
        </div>
      </div>
    </div>
    <van-divider/>
    <van-cell title="我的考试" @click="showExam" icon="records" isLink/>
    <van-cell title="我的收藏" @click="showCollect" icon="like-o" isLink/>
    <van-cell title="我的评论" @click="showComment" icon="like-o" isLink/>
    <van-divider/>
    <van-cell title="退出" @click="logout" icon="close" isLink/>
  </div>

</template>

<script setup lang="ts">
import {ref,reactive,toRefs} from "vue";
import {useRouter} from "vue-router";
let userinfo = JSON.parse(localStorage.getItem('hsjyUserInfo'))
let state = reactive({
  userinfo,
    })
console.log(userinfo)
const img_prefix_url ="https://yw.52kfw.cn"
const router=useRouter()
const logout = ()=>{
  localStorage.removeItem('hsjyToken')
  localStorage.removeItem('id')
  localStorage.removeItem('username')
  localStorage.removeItem('hsjyUserInfo')
  router.push('/')
}
const setting =()=>{
  router.push('/setting')
}
const showExam =()=>{
  router.push('/show/myexams')
}
const showCollect =()=>{
  router.push('/show/collects')
}
const showComment =()=>{
  router.push('/show/comments')
}

</script>

<style scoped lang="less">
.userinfo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0.2rem;
  background-color: #fff;
  .left {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .avatar {
      width: 1.2rem;
      height: 1.2rem;
      margin-right: 0.2rem;
      img {
        width: 100%;
      }
    }
    .info {
      > h2 {
        font-weight: 700;
        margin-bottom: 0.2rem;
      }
      > p {
        color: #454545;
      }
    }
  }
  .right {
    .setting {
      font-size: 0.6rem;
    }
  }
  .van-cell {
    border-bottom: 2px solid #c6e2ff;
  }
}
</style>
